package com.buba.controller;


import com.buba.service.MaintenanceLevelService;
import common.R;
import entity.maintenance.MaintenanceLevel;
import entity.maintenance.dto.MaintenanceLevelDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import utils.pageutil.PageRequest;
import utils.pageutil.PageResult;

import java.beans.PropertyVetoException;
import java.util.List;

/**
 * <p>
 * 保养级别 前端控制器
 * </p>
 *
 * @author beisheng
 * @since 2023-05-18
 */
@RestController
@RequestMapping("/maintenance-level")
public class MaintenanceLevelController {
    @Autowired
    private MaintenanceLevelService maintenanceLevelService;

    /**
     * 编辑保养等级
     * @param maintenanceLevel
     * @return
     */
    @PostMapping("updateMaintenanceLevel")
    public R updateMaintenanceLevel(@RequestBody MaintenanceLevel maintenanceLevel) {
        boolean b = maintenanceLevelService.updateMaintenanceLevel(maintenanceLevel);
        return b ? R.success() : R.error();
    }

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @PostMapping("delMaintenanceLevel")
    public R delMaintenanceLevel(@RequestBody List<Integer> ids) {
        boolean b = maintenanceLevelService.delMaintenanceLevel(ids);
        return b ? R.success() : R.error();
    }

    /**
     * 添加保养级别信息
     *
     * @param maintenanceLevel
     * @return
     */
    @PostMapping("insMaintenanceLevel")
    public R insMaintenanceLevel(@RequestBody MaintenanceLevel maintenanceLevel) {
        boolean b = maintenanceLevelService.insMaintenanceLevel(maintenanceLevel);
        return b ? R.success() : R.error();
    }

    /**
     * @Author atlong
     * @Description 分页模糊全查
     * @Date 2023/5/30 17:02
     * @Param [maintenanceLevelDto]
     * @return common.R
     **/
    @PostMapping("selMaintenanceLevel")
    public R selMaintenanceLevel(@RequestBody MaintenanceLevelDto maintenanceLevelDto) {
        PageResult pageResult = maintenanceLevelService.selMaintenanceLevel(maintenanceLevelDto);
        return R.success(pageResult);
    }

}

